<include file="Public:header" />
<script type="text/javascript" src="__PUBLIC__/js/kindeditor-all-min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/zh_CN.js"></script>
<link rel="stylesheet" href="__PUBLIC__/css/kindeditor.css" type="text/css" />
<script type="text/javascript">
	<if condition="C('ismobile') neq 1">
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="content"]', {
				uploadJson:'{:U("file/editor")}',
				allowFileManager : true,
				loadStyleMode : false,
				fileManagerJson: "{:U('file/manager')}"
			});
		});
	</if>
</script>
<div class="container">
	<div class="page-header">
		<h4>{:L('CONTRACT_EDITOR')}</h4>
	</div>
	<include file="Public:alert"/>
	<div class="row">
		<div class="tabbable span12">
			<div class="tab-content">
				<div class="tab-pane active" id="tab1">
				<form action="{:U('contract/edit')}" method="post">
				<input type="hidden" name="id" value="{$info.contract_id}">
				<input type="hidden" name="total_amount" id="total_amount" value="0">
					<table class="table table-hover">
						<thead>
							<tr>
								<td>&nbsp;</td>
								<td <if condition="C('ismobile') neq 1">colspan="3"</if>><input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp;<input type="button" class="btn" onclick="javascript:history.go(-1)" value="{:L('RETURN')}"/></td>
							</tr>
						</thead>
						<tbody>
							<tr><th <if condition="C('ismobile') eq 1">colspan="2"<else />colspan="4"</if>>{:L('BASIC_INFO')}</th></tr>
							<tr>
								<td class="tdleft">{:L('CONTRACT_NO')}</td>
								<td><input  type="text" name="number" id="number" value="{$info.number}"></td>
								<if condition="C('ismobile') eq 1"></tr><tr></if>
								<td class="tdleft">{:L('BUSINESS_OPPORTUNITIES_CLICK_ON_THE_SELECT')}</td>
								<td><input type="hidden" name="business_id" id="business_id" value="{$info.business_id}"/><input type="text" name="business_name" id="business_name" value="{$info.business_name}"> </td>
							</tr>
							<tr>
								<td class="tdleft">{:L('CONTACTS')}</td>
								<td><input type="text" readonly="readonly" id="contacts_name" value="{$info.contacts_name}"/></td>
								<if condition="C('ismobile') eq 1"></tr><tr></if>
								<td class="tdleft">{:L('CUSTOMER')}</td>
								<td><input type="text" readonly="readonly" id="customer_name" value="{$info.customer_name}"> </td>
							</tr>
							<tr>
								<td class="tdleft">{:L('OWNER_ROLE_CLICK_ON_THE_SELECT')}</td>
								<td><input type="hidden" name="owner_role_id" id="owner_id" value="{$info.owner_role_id}"/>
								<input type="text" name="owner_role_name" id="owner_name" value="{$info.owner_name}"/></td>
								
								<if condition="C('ismobile') eq 1"></tr><tr></if>
								<td class="tdleft">{:L('QUOTATION')}</td>
								<td><input type="text" name="price" id="price" value="{$info.price}"/></td>
							</tr>
							<tr>
								<td class="tdleft">{:L('THE_TIME_WHICH_THE_CONTRACT_COMES_INTO_FORCE')}</td>
								<td>
									<input type="text" id="start_date" name="start_date" onClick="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:&quot;#F{$dp.$D('end_date')||'2038-01-01'}&quot;})" class="Wdate" <if condition="$info['start_date']">value="{$info['start_date']|date="Y-m-d",###}"</if>/>
								</td>
								<if condition="C('ismobile') eq 1"></tr><tr></if>
								<td class="tdleft">{:L('CONTRACT_TIME')}</td>
								<td>
									<input type="text" id="end_date" onClick="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:&quot;#F{$dp.$D(\'start_date\')}&quot;,maxDate:'2038-01-01'})" name="end_date" class="Wdate" <if condition="$info['end_date']">value="{$info['end_date']|date="Y-m-d",###}"</if>/>
								</td>
							</tr>
							<tr>
								<td class="tdleft">{:L('STATUS')}</td>
								<td>
									<select name="status" id="status">
										<option value="{:L('HAS_BEEN_CREATED')}" <if condition="$info.status eq L('HAS_BEEN_CREATED')">selected="selected"</if>>{:L('HAS_BEEN_CREATED')}</option>
										<option value="{:L('APPROVED')}" <if condition="$info.status eq L('APPROVED')">selected="selected"</if>>{:L('APPROVED')}</option>
										<option value="{:L('PERFORMANCE_OF_THE_FINISHED')}" <if condition="$info.status eq L('PERFORMANCE_OF_THE_FINISHED')">selected="selected"</if>>{:L('PERFORMANCE_OF_THE_FINISHED')}</option>
									</select><div id="contract_status_tips" style="color:#005580;"></div>
								</td>
								<if condition="C('ismobile') eq 1"></tr><tr></if>
								<td class="tdleft">{:L('SIGNING_TIME')}</td>
								<td><input onclick="WdatePicker()"  type="text" id="due_time" name="due_time" value="{$info.due_time|date='Y-m-d',###}" /></td>
							</tr>
							<tr>
								<td class="tdleft">{:L('THE_TERMS_OF_THE_CONTRACT')}</td>
								<td <if condition="C('ismobile') neq 1">colspan="3"</if>><textarea class="span6" rows="3" name="content" id="content" style="width: 800px; height: 350px;">{$info.content}</textarea></td>
							</tr><tr>
								<td class="tdleft">{:L('DESCRIBE')}</td>
								<td <if condition="C('ismobile') neq 1">colspan="3"</if>><textarea class="span6" rows="3" name="description" id="description">{$info.description}</textarea></td>
							</tr>
						</tbody>
						<tfoot>
							<tr>
								<td>&nbsp;</td>
								<td colspan="3">
									<input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp;
									<input type="button" class="btn" onclick="javascript:history.go(-1)" value="{:L('RETURN')}"/>
								</td>
							</tr>
						</tfoot>
					</table>
				</form>
				</div>
			</div>
		</div>
	</div>
</div>
<div id="dialog-business" title="{:L('SELECT_BUSINESS_OPPORTUNITIES')}">loading...</div>
<div id="dialog-role-list2" title="{:L('SELECT_HEAD')}">loading...</div>
<script type="text/javascript">
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>
	$(function(){
		$('#business_name').click(function () {
			$('#dialog-business').dialog('open');
			$('#dialog-business').load("{:U('business/listDialog')}");
		});
		
		$('#owner_name').click(function () {
			$('#dialog-role-list2').dialog('open');
			$('#dialog-role-list2').load('{:U("user/listDialog")}');
			return false;
		});
	});
	$('#dialog-business').dialog({
		autoOpen: false,
		modal: true,
		width: width,
		maxHeight: 400,
		buttons: {
			"Ok": function () {
				var item = $('input:radio[name="business"]:checked').val();
				var name = $('input:radio[name="business"]:checked').parent().next().html();
				var name2 = $('input:radio[name="business"]:checked').parent().next().next().find('a').html();
				var name3 = $('input:radio[name="business"]:checked').parent().next().next().next().find('a').html();
				$('#business_name').val(name);
				$('#business_id').val(item);
				$('#customer_name').val(name2);
				$('#contacts_name').val(name3);
				if ($('input[name="name"]').val() == "")$('input[name="name"]').val(name);
				
				$(this).dialog("close");
			},
			"Cancel": function () {
				$(this).dialog("close");
			}
		},
		position:["center",100]
	});
	$("#dialog-role-list2").dialog({
		autoOpen: false,
		modal: true,
		width: width,
		maxHeight: 400,
		buttons: { 
			"Ok": function () {
				var item = $('input:radio[name="owner"]:checked').val();
				var name = $('input:radio[name="owner"]:checked').parent().next().html();
				$('#owner_id').val(item);
				$('#owner_name').val(name);
				$(this).dialog("close"); 
			},
			"Cancel": function () {
				$(this).dialog("close");
			}
		},
		position: ["center", 100]
	});
</script>
<include file="Public:footer" />	